﻿using System.Collections.Generic;
using JetBrains.Annotations;

namespace MugenMvvmToolkit.Interfaces
{
    /// <summary>
    ///     Represents interface for validate objects.
    /// </summary>
    public interface IValidationProvider
    {
        /// <summary>
        ///     Determines whether the specified object is valid using the validation context.
        /// </summary>
        /// <param name="instance">The object to validate.</param>
        /// <param name="breakOnFirstError">
        ///     If <c>true</c> break check on first error, otherwise <c>false</c>.
        /// </param>
        /// <param name="validationResults">The collection to write validation results.</param>
        /// <param name="validationMetadata">The specified validation metadata. It's optional parameter.</param>
        void ValidateObject([NotNull]object instance, bool breakOnFirstError, [NotNull]IList<IValidationResult> validationResults,
                            [CanBeNull]IDictionary<object, object> validationMetadata);

        /// <summary>
        ///     Determines whether the specified object property is valid using the validation context.
        /// </summary>
        /// <param name="instance">The object to validate.</param>
        /// <param name="propertyName">The specified property name to validate.</param>
        /// <param name="validationResults">The collection to write validation results.</param>
        /// <param name="validationMetadata">The specified validation metadata. It's optional parameter.</param>
        void ValidateProperty([NotNull]object instance, string propertyName, [NotNull]IList<IValidationResult> validationResults,
                              [CanBeNull]IDictionary<object, object> validationMetadata);

        /// <summary>
        ///     Fills errors from validation result to dictionary.
        /// </summary>
        /// <param name="validationResults">The collection with validation results.</param>
        /// <param name="dictionary">
        ///     An instance of <see cref="IDictionary{TKey,TValue}" />
        /// </param>
        void FillErrors([NotNull]IList<IValidationResult> validationResults,
                        [NotNull]IDictionary<string, IList<IValidationResult>> dictionary);
    }
}